home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
8_5.lha
/
8_5
/
fread.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
729b
|
35 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ read in num objects of the given size into the buffer
nt fread(void *vbuf, unsigned int size,
unsigned int num, FILE *f)
char *buf = (char*)vbuf;
if (f->mode == input)
{
// read in num * size bytes
for (unsigned int n = num; n-- > 0; )
for (unsigned int s = size; s-- > 0; )
{
char c;
if (f->in->get(c))
*buf++ = c;
else
// The end of the input
// partway through an object.
// Return the number of complete
// objects read so far.
return num - n;
}
// Return the number of
// complete objects read.
return num - n;
}
return 0;